package designPatterns_demo.adapter_pattern.class_adapter.demo1;

public class AudioPlayer implements MediaPlayer {
	MediaAdapter mediaAdapter;
	
	@Override
	public void play(String audioType, String fileName) {
		// 播放 mp3 音乐文件的内置支持
		if (audioType.equals("mp3")) {
			System.out.println("Playing mp3 file. Name: "+ fileName);
		} else if (audioType.equals("vlc") || audioType.equals("mp4")) { // mediaAdapter 提供了播放其他文件格式的支持
			mediaAdapter = new MediaAdapter(audioType);
			mediaAdapter.play(audioType, fileName);
		} else {
			System.out.println("Invalid media. "+ audioType + " format not supported");
		}
	}

}
